<template>
  <div style="padding:20px; padding-bottom:100px;">
    <el-table
      :data="tableData"
      style="width: 100%"
      v-loading = "isLoading"
      element-loading-text = "数据正在加载中"
      element-loading-spinner = "el-icon-loading"
    >
      <el-table-column
        label="学生姓名"
      >
        <template slot-scope="scope">
          <i class="el-icon-time" />
          <span style="margin-left: 10px">{{ scope.row.NAME }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="身份证号"
      >
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top">
            <p>学生姓名: {{ scope.row.NAME }}</p>
            <p>身份证号: {{ scope.row.id_card }}</p>
            <div slot="reference" class="name-wrapper">
              <el-tag size="medium">{{ scope.row.id_card }}</el-tag>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column
        label="异差类型"
      >
        <template slot-scope="scope">
          <i class="el-icon-star-off" />
          <span style="margin-left: 10px">{{ scope.row.difference_type }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="异差内容"
      >
        <template slot-scope="scope">
          <i class="el-icon-star-off" />
          <span style="margin-left: 10px">{{ scope.row.difference_content }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="校验时间"
      >
        <template slot-scope="scope">
          <i class="el-icon-star-off" />
          <span style="margin-left: 10px">{{ scope.row.check_time }}</span>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="totals>0" :total="totals" :page.sync="pagination.num" :limit.sync="pagination.size" @pagination="selectDifferenceData" />
  </div>
</template>
<script>
import Pagination from '@/components/Pagination'
export default {
  components: { Pagination },
  name:'FinanceOffice',
  data() {
    return {
      isLoading:false,
      pagination: {
        size: 15,
        num: 1
      },
      totals: 0,
      tableData: [],
      tableName: ['student_source', 'student_basic_info_student_worker', 'student_status_educational', 'payment_information'],
      tableLabel: [],
      tableFiled: [],
      allStudentData: []
    }
  },
  mounted() {
    this.isLoading = true;
    this.selectAllTableFiled(this.tableName)
    this.selectDifferenceData()
  },
  methods: {
    selectDifferenceData() {
      var params1 = {}
      params1.pageSize = this.pagination.size
      params1.pageNum = this.pagination.num
      this.$get('dataCenter/financeOffice', {
        ...params1
      }).then((r) => {
        this.isLoading = false;
        const data = r.data.data
        this.tableData = data
        this.totals = r.data.count
        // this.selectDifferenceStudentStatus()
      })
    },
    selectDifferenceStudentStatus() {
      var tableFiled = this.tableFiled
      var params1 = {}
      var params = JSON.stringify(params1)
      this.$post('dataCenter/selectCurrency', {
        params, tableFiled
      }).then((r) => {
        
        const data = r.data.data
        this.allStudentData = data
        for (var i = 0; i < data.length; i++) {
          if (data[i].student_basic_info_student_worker__status_of_student_status !== data[i].student_status_educational__xuexin_registered && data[i].student_basic_info_student_worker__id_card === data[i].student_status_educational__id_card) {
            this.tableData.push({ 'NAME': data[i].student_status_educational__student_name, 'id_card': data[i].student_status_educational__id_card, 'difference_type': '数据不匹配', 'difference_content': '字段【学籍状态】与其他系统不一致, 教务系统为【' + data[i].student_status_educational__xuexin_registered + '】，学工系统为【' + data[i].student_basic_info_student_worker__status_of_student_status + '】', 'inspect_time': new Date() })
          }
        }
      })
    },
    selectAllTableFiled(tableName) {
      var baseName = 'febs_cloud_base'
      this.tableLabel = []
      this.tableFiled = []
      this.$get('dataCenter/selectAllTableField', {
        baseName, tableName
      }).then((r) => {
        const data = r.data.data
        for (var i = 0; i < data.length; i++) {
          var COLUMN_NAMES = data[i].COLUMN_NAME.replace('.', '__')
          this.tableLabel.push({ label: data[i].column_comment, prop: COLUMN_NAMES })
          this.tableFiled.push(data[i].COLUMN_NAME)
        }
      })
      this.loading = false
    }
  }
}
</script>

